//
//  BLEManager.h
//  DefendHealth
//
//  Created by 吾诺瀚卓 on 17/3/2.
//  Copyright © 2017年 iMacOne. All rights reserved.
//

#import <Foundation/Foundation.h>

#import <CoreBluetooth/CoreBluetooth.h>

#define SERVICE_UUID     0xFFE0
#define CHAR_UUID        0xFFE1

@protocol SmartSensorDelegate <NSObject>

@optional
//返回查找的外设
-(void)peripheralFound:(CBPeripheral *)peripheral;
//蓝牙返回的数据
-(void)bleCharValueUpdated: (NSString *)UUID value: (NSData *)data;
//链接
-(void)setConnect;
//断开链接
-(void)setDisconnect;
@end

@interface BLEManager : NSObject<CBCentralManagerDelegate, CBPeripheralDelegate>
@property (nonatomic,strong) NSMutableArray *peripherals;
@property (nonatomic,strong) CBCentralManager *manager;
@property (nonatomic,strong) CBPeripheral *activePeripheral;
@property (nonatomic, assign) id <SmartSensorDelegate> delegate;

#pragma mark-方法
+(BLEManager *)sharedManager;

-(void)setup; //controller setup
//查找所有蓝牙设备
-(int)findBLEAppPeripherals:(int)timeout;
-(void)scanTimer:(NSTimer *)timer;
//链接外设
-(void)connect:(CBPeripheral *)peripheral;
//断开外设
-(void)disconnect:(CBPeripheral *)peripheral;
//发送数据给外设
-(void)write:(CBPeripheral *)peripheral data:(NSData *)data;


//打印外设信息
-(void)printPeripheralInfo:(CBPeripheral*)peripheral;




@end
